package com.leon.alishop.core.bof.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.leon.alishop.core.bo.ProviderBo;
import com.leon.alishop.core.bof.ProviderBof;
import com.leon.alishop.core.page.Page;
import com.leon.alishop.core.vo.ProviderParams;
import com.leon.alishop.dao.ProviderInfoDao;
import com.leon.alishop.model.ProviderInfo;

@Service("providerBof")
public class ProviderBofImpl implements ProviderBof{

	@Override
	public List<ProviderBo> showProviderBoList(ProviderParams params, Page page) {
		if(page == null){
			page = new Page(300);
		}
		if(params==null)
			params = new ProviderParams();
		List<ProviderBo> ret = new ArrayList<ProviderBo>();
		
		List<ProviderInfo> proInfoList = providerdDao.findAllProviderInfo(
				params.getId(),
				params.getStatus(),
				page.getFirstRow(), 
				page.getPageSize());
		ProviderBo pb = null;
		if(null != proInfoList){
			for (ProviderInfo pi : proInfoList) {
				pb = new ProviderBo();
				BeanUtils.copyProperties(pi, pb);
				ret.add(pb);
			}
		}
		return ret;
	}
	
	@Autowired
	private ProviderInfoDao providerdDao;

}
